package pers.karl.design.structure.flyweight;

import java.util.LinkedList;
import java.util.List;

/**
 * 围棋游戏（棋局）
 *   负责存储外部状态
 */
public class ChessGame {

    /**
     * 棋子的位置
     */
    private List<String> positionList;

    public ChessGame() {
        positionList = new LinkedList<>();
    }


    public void xiaqi(String color, int posX, int posY) {
        // 获取棋子
        Chessman chessman = ChessmanFactory.getInstance().getChessman("round", color, 1);

        // 落子
        chessman.show(posX,posY);
        this.positionList.add(posX + "," + posY);

        // 根据规则计算
        this.checkRule();
    }

    // 检查围棋规则
    private void checkRule() {

    }

    public static void main(String[] args) {
        ChessGame chessGame = new ChessGame();

        // 下棋
        chessGame.xiaqi("black", 1, 2);
        chessGame.xiaqi("white", 1, 3);


    }

}
